import { create } from 'zustand'

// 定义 defaultModel 的类型
interface ModelStore {
    idSpace: string;
    vluTabSource?: string;
    vluModelName: string;
    userCreated?: string;
    timeCreated?: string;
    timeUpdated?: string;
    setFilename: (name: string) => void;
    setIdSpace: (idSpace: string) => void;
    updateFormValues: (form: typeof defaultModel) => void;
    [key: string]: any;
}

const defaultModel = {
    vluTabSource: 'GAUSS',
    vluModelType: 'lowcode',
    vluModelName: '未命名文件',
    idSpace: '67ce9f4d71a5996de21d82c9',
    timeCreated: '',
    timeUpdated: '',
    userCreated: '',
    txtDescription: '',
}
export const useModelStore = create<ModelStore>((set) => ({
    ...defaultModel,
    setTableSource: (ds: string) => set({ vluTabSource: ds }),
    setFilename: (name: string) => set({ vluModelName: name }),
    setUserCreated: (user: string) => set({ userCreated: user }),
    setTimeCreated: (time: string) => set({ timeCreated: time }),
    setTimeUpdated: (time: string) => set({ timeUpdated: time }),
    setIdSpace: (idSpace: string) => set({ idSpace }),
    updateFormValues: (form: typeof defaultModel) => set({...form})
}));
